<?php

include_once('ConnectionManager.php');

function loadImagesByID($imageID) {
    $query = "SELECT * FROM IMAGE WHERE IMG_ID = $imageID";
    ConnectionManager::getInstance()->setQuery($query);
    ConnectionManager::getInstance()->query();
    return ConnectionManager::getInstance()->fetchArray();
}

function loadImagesByProductID($proID) {
    $query = "SELECT * FROM IMAGE WHERE PRO_ID = $proID";
    ConnectionManager::getInstance()->setQuery($query);
   return ConnectionManager::getInstance()->query();
}

function insertImage($proID, $fileName) {
    $query = "INSERT INTO IMAGE (PRO_ID, IMG_PATH) VALUES ($proID, '$fileName')";
    ConnectionManager::getInstance()->setQuery($query);
    $result = ConnectionManager::getInstance()->query();
    return $result;
}

function updateImage($imgID, $fileName) {
    $query = "UPDATE IMAGE SET IMG_PATH = '$fileName' WHERE IMG_ID = $imgID";
    ConnectionManager::getInstance()->setQuery($query);
    $result = ConnectionManager::getInstance()->query();
    return $result;
}

?>